package main;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author chau
 */
public class ShortShowBox extends ShortShowObject {

    private String textShow;
    private int boxX;
    private int boxY;
    private int boxWidth;
  //  private Canvas parent;

    public ShortShowBox() {
    }

    public void setText(String text) {
        this.textShow = text;
        int messageWidth = PiPoDesigner.stringWidth(text);
        boxWidth = messageWidth + 10;
    }

    public void setPosition(int x, int y) {
        this.boxX = x;
        this.boxY = y;
    }

    public int getBoxWidth() {
        return this.boxWidth;
    }

    public void paintObject(Graphics g) {
        int messageWidth = PiPoDesigner.stringWidth(textShow);
        int boxChatWidth = messageWidth + 10;
        int boxChatHeight = 30;
        boxWidth = boxChatWidth;
        g.setColor(0xffffff);
        g.fillRoundRect(boxX, boxY, boxChatWidth, boxChatHeight, 17, 17);
        g.setColor(0x00000);
        g.drawRoundRect(boxX, boxY, boxChatWidth, boxChatHeight, 17, 17);
        PiPoDesigner.drawString(g, textShow, PiPoDesigner.COLOR_BLACK, PiPoDesigner.COLOR_YELOW, boxX + boxChatWidth / 2 - messageWidth / 2, boxY + boxChatHeight / 2 - 8);
    }

    public void doLoop() {
    }

    public void doWhenStop() {
        textShow = "";
    }
}
